#include "config.h"

#include "ms2lstat.h"

ecm_hashtable_t	hash_player;
static ecm_ptrs_t	*ptrs_player;

static player_t *
create_player(const char *desc)
{
	player_t	*player;

	player = (player_t *)ecm_malloc(sizeof(player_t));
	player->pid = ecm_ptrs_add(ptrs_player, player);
	player->player_desc = ecm_strdup(desc);
	player->accessed_count = 0;

	ecm_hashtable_str_insert(hash_player, player, desc);

	return player;
}

ecm_uint32
get_player_id(const char *player_desc)
{
	player_t	*player;

	player = (player_t *)ecm_hashtable_str_get(hash_player, player_desc);
	if (player == NULL) {
		player = create_player(player_desc);
	}
	return player->pid;
}

void
report_player_result(FILE *fp)
{
	ecm_fprintf(fp, "Total Number of Players:            %u\n", ecm_hashtable_getsize(hash_player));
}

ECMBOOL
init_player(void)
{
	hash_player = ecm_hashtable_create(256);
	ptrs_player = ecm_ptrs_new(256);

	return ECM_TRUE;
}



